package com.example.controller.institutioncare;

import com.example.utils.Resss;
import com.qiniu.util.Auth;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import java.util.UUID;

@CrossOrigin
@RestController
@Api(tags="获取上传token")
@RequestMapping("/test")
public class UploadController{

    /**
     * @ApiImplicitParams
     * value:参数的描述buname 空间名
     * required://是否必须传入
     * paramType:定义参数传递类型:有path,query,body,form,header
     * */
    @ApiOperation(value="获得token",notes="养老系统登录")
    @GetMapping("/upload/{buname}")
    @ApiImplicitParams({@ApiImplicitParam(name="buname",value="buname",required=true,paramType="path")})
    public Resss getbyid(@PathVariable String buname){
        String accessKey="TpM2lYoiWcNSbKSFsbM54UpKXT5L-kP-8X8Y6kqA"; //你自己的key
        String secretKey="wbx1aO2Lsz3gn89FbkLvLuLiWc6nHVjSFt5PTIXb"; //你自己的密钥
        Auth auth=Auth.create(accessKey,secretKey);
        UUID m=UUID.randomUUID();
        String fname="test"+m;
        String token=auth.uploadToken("lisi233",fname);//你自己空间的名称
        System.err.println(buname+"得到的空间名");
        System.out.println(fname);
        System.out.println(token);
        return new Resss().code(1001).data("token",token).data("fname",fname);
    }
}